function CalendarTabController(calendarViewBody, tab, handIcon, toggleIcons) {
    this._calendarViewBody = calendarViewBody;
    this._tab = tab;
    this._handIcon = handIcon;
    this._toggleIcons = toggleIcons;
    this._headerTabItems = $("ul > li.item", this._tab);
    this._contentItems = $(".tab-content  div.ribbon", this._tab);
    this._sectionItems = $(".tab-content  div.section", this._tab);
    this._guideItems = $(".txtcontent");
}

CalendarTabController.prototype = {
    register: function() {
        var me = this;

        this._headerTabItems.click(function(e) {
            var isFromOverviewTab = $(me._headerTabItems[0]).hasClass("selected");  
            
            me._switchTab($(e.target));
            me._handIcon.activate();
            me._calendarViewBody.restoreDefaultMode();

            if (isFromOverviewTab) {
                me._calendarViewBody.updateLocations();
            }

            e.preventDefault();
        });

        this._toggleIcons.foreach(function(icon) {
            icon.onActivating(function() {
                me._deactivateAllIcons();
            });
        });
    },
    _deactivateAllIcons: function() {
        this._toggleIcons.foreach(function(icon) {
            icon.deactivate();
        });
    },
    _switchTab: function(tabItem) {
        this._switchHeader(tabItem);
        this._switchContent(tabItem);
        this._switchSection(tabItem);
        this._switchGuide(tabItem);
    },

    _switchHeader: function(tabItem) {
        var tabSelectedClass = "selected";
        this._headerTabItems.removeClass(tabSelectedClass);
        tabItem.parent(".item").addClass(tabSelectedClass);
    },

    _switchContent: function(tabItem) {
        var hiddenClass = 'hidden';
        var contentId = '#' + tabItem.attr('tabId');
        this._contentItems.addClass(hiddenClass);
        $(contentId, this._tab).removeClass(hiddenClass);
    },

    _switchGuide: function(tabItem) {
        var hiddenClass = 'hidden';
        var guidId = '#' + tabItem.attr('guideId');
        this._guideItems.addClass(hiddenClass);
        $(guidId).removeClass(hiddenClass);
    },

    _switchSection: function(tabItem) {
        var hiddenClass = 'hidden';
        var sectionId = '#' + tabItem.attr('sectionId');
        this._sectionItems.addClass(hiddenClass);
        $(sectionId, this._tab).removeClass(hiddenClass);
    }
};
